#include "swpsimjoingraphicitem.h"

#include "graphicitemcommon.h"

using namespace core;
using namespace swp;

SwpSimJoinGraphicItem::SwpSimJoinGraphicItem(QGraphicsItem* parent) :
    SwpJoinGraphicItem(parent), ISimItem(),
    m_isInSimPath(false),
    m_originId()
{
    setFlag(QGraphicsItem::ItemIsMovable, false);
}

SwpSimJoinGraphicItem::SwpSimJoinGraphicItem(SwpJoinGraphicItem* from,
    QGraphicsItem* parent) : SwpJoinGraphicItem(parent), ISimItem(),
        m_isInSimPath(false),
        m_originId(from->id())
{
    setFlag(QGraphicsItem::ItemIsMovable, false);

    setPos(from->pos());
}

SwpSimJoinGraphicItem::~SwpSimJoinGraphicItem()
{

}

bool SwpSimJoinGraphicItem::supportsConnection(
        const ConnectionData& connection) const
{
    return connection.ConnectionId == CONNECTION_SIM_PATH;
}

int SwpSimJoinGraphicItem::type() const
{
    return SWP_SIM_JOIN_ITEM;
}

IEditorItem* SwpSimJoinGraphicItem::copy() const
{
    return new SwpSimJoinGraphicItem();
}

bool SwpSimJoinGraphicItem::isInSimPath() const
{
    return m_isInSimPath;
}

void SwpSimJoinGraphicItem::setInSimPath(bool in)
{
    if (in)
    {
        setBrush(QBrush(m_palette->acceptsConnectionColor()));
    }
    else
    {
        setBrush(QBrush(m_palette->borderColor()));
    }

    m_isInSimPath = in;
}

QUuid SwpSimJoinGraphicItem::originId() const
{
    return m_originId;
}
